<template>
	<view>
		<view class="list-box">
			<view class="item-box" v-for="(item, key) in goodsList" @click="gotoDetail(item.id)">
				<!-- 基本信息 -->
				<view class="info-box row-box">
					<view style="width: 86%;">
						<view style="font-size: 32rpx;font-weight: 900;">{{item.modelName}}</view>
					</view>
					<view class="center-box">
						<u-tag size="mini" v-if="item.status === 1" type="primary" text="询价中"></u-tag>
						<u-tag size="mini" v-if="item.status === 2" type="success" text="已回收"></u-tag>
						<u-tag size="mini" v-if="item.status === 3" type="info" text="结束"></u-tag>
					</view>
				</view>
				
				<view style="border-top: #c0c4cc 1px solid;"></view>
				
				<view class="row-box date-box">
					<view style="width: 60%;">店员：{{item.nickName}}</view>
					<view style="width: 40%;text-align: right;">{{item.createTime}}</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				goodsList: [],
			}
		},
		created() {
			this.getList();
		},
		methods: {
			getList() {
				this.$request("/appShopApi/order/inquiry/all/list", 'get').then(res => {
					console.log("当前获取的列表信息: ", res);
					this.goodsList = res.data;
					this.goodsList.forEach(it => {
						it.status = this.booleanStatu(it);
					})
				})
			},
			//详情
			gotoDetail(id) {
				uni.navigateTo({
					url: "/pages/store/inquiry/details?id=" + id,
				})
			},
			/* 状态判断 1=询价中, 2=已回收, 3=超时未报价 */
			booleanStatu(row) {
				let now = new Date().getTime();
				let end = new Date(row.createTime).getTime() + 1000*60*10;
				if(now > end) {
					if(row.offerId)
						return 2;
					else
						return 3;
				}
				return 1;
			},
		}
	}
</script>

<style scoped lang="scss">
	.list-box {
		margin-top: 20rpx;
		.item-box {
			background-color: #fff;
			border-radius: 20rpx;
			padding: 20rpx;
			margin: 30rpx;
			line-height: 60rpx;
			.title-box {
				font-size: 32rpx;
				font-weight: 600;
			}
			.date-box {
				font-size: 22rpx;
			}
			.info-box {
				margin-top: 20rpx;
			}
		}
	}
</style>
